# TODO
# make pygame version
# make dsl version
# make suckless sent powerpoint automation that displays 23 notes then 4 rests (at tempo 202), 3 notes then 1 rest (at tempo 8), etc...

import time
import os


def clear():
    os.system("cls" if os.name == "nt" else "clear")


def give_count_in():
    clear()
    counts = ["one", "two", "three", "four"]
    for countindex in counts:
        print(countindex + "!")
        time.sleep(1)
        clear()
    clear()


def print_score(note, rest, guitar, bpm):
    clear()
    quarter = "\u2669"
    print(
        "play "
        + str(note)
        + " notes"
        + " then "
        + str(rest)
        + " rests at "
        + quarter
        + " = "
        + str(bpm)
        + " ("
        + guitar
        + ")"
    )


def get_seconds_total_of_measure():
    "not implemented"
    pass


def get_preview_of_upcoming_measure():
    "not implemented"
    pass


def print_notes(counter, sleep):
    print(str(counter))
    time.sleep(sleep)


def print_rests(rest, sleep):
    print("rest for " + str(rest) + " beats!")
    for rest in range(rest):
        print(str(rest + 1))
        time.sleep(sleep)


def main(guitar, note, rest, bpm):
    clear()
    sleep = 60.0 / bpm
    counter = 0
    while True:
        counter += 1
        if counter == 1:
            print_score(note, rest, guitar, bpm)
        if counter <= note:
            print_notes(counter, sleep)
        elif counter > note:
            clear()
            print_rests(rest, sleep)
            clear()
            break


# for guitar Erik Carlson
give_count_in()
main("G# third string", 23, 4, 202)
main("F sixth string", 3, 1, 8)
main("A# third string", 5, 15, 120)
main("D open string", 6, 14, 75)
main("F fourth string", 20, 8, 70)
main("C fifth string", 16, 19, 45)
main("C# second string", 8, 5, 65)
main("C# fifth string", 1, 6, 209)
main("G open string", 7, 2, 38)
main("B open string", 15, 21, 54)
main("G sixth string", 13, 13, 60)
main("A third string", 12, 17, 41)

print("second page\n")

main("D# fourth string", 17, 23, 109)
main("D second string", 14, 11, 250)
main("C second string", 24, 24, 60)
main("A# fifth string", 18, 3, 315)
main("F# sixth string", 21, 20, 55)
main("D# second string", 10, 22, 96)
main("E open string", 22, 7, 58)
main("B fifth string", 9, 12, 70)
main("E fourth string", 4, 10, 23)
main("F# fourth string", 19, 18, 58)
main("A open string", 2, 9, 19)
main("G# sixth string", 11, 16, 50)

if __name__ == "__main__":
    main()
